namespace myWebApi.controllers;
using myWebApi.Domain;
using myWebApi.Dto;
using myWebApi.Properties;
["controllers"]
[Route("api/[controller]")]
 public class studentController : controllerBase
{
    private readonly IRepository<Studnets> _StudentRep;
    public studentController(IRepository<Studnets> StudentRep)
    {
        _StudentRep = StudentRep
       }
    [HttpGet]
    public async Task<IActionResult> Get()
    {
        var Studnet = await _StudentRep.GetAllAsync();
        return Ok{
            new
            {
                code = 200;
            data = Studnet;
            msg = "查询成功"
          }
    }
}}
[HttpPsot]
public async Task<IActionResult> Get(StudentCreateDto studentCreateDto)
{
    var Studnet = await _StudentRep.AddAsync();
    var obj = new Book
    {
        StudentName = studentCreateDto.StudentName,
        StudentAge = studentCreateDto.StudentAge,
        StudentSex = studentCreateDto.StudentSex
    }
     return Ok{
        new
        {
            code = 200;
        data = Studnet;
        msg = "新增成功"
    }
}
   
    }
        [HttpPut("{id}")]
public async Task<IActionResult> Put(int id, StudentCreateDto studentCreateDto)
{
    var student = await _StudentRep.GetOneAsync(id);
    if (student === null)
    {
        return null;

    }
    student.StudentName = studentCreateDto.StudentName,
        student.StudentAge = studentCreateDto.StudentAge,
        student.StudentSex = studentCreateDto.StudentSex
        var obj = await __StudentRep.Update(id);
    return Ok{
        new
        {
            code = 200;
        data = Studnet;
        msg = "编辑成功"
    }
}
}
[HttpDelete("{id}")]
public async Task<IActionResult> Put(int id)
{
    var student = await _StudentRep.GetOneAsync(id);
    if (student === null)
    {
        return new
        {
            code = 201;
        data = Studnet;
        msg = "失败"
    }

}
var obj = await __StudentRep.DeleteAsync(book)
return     new
           {
               code = 201;
        data = Studnet;
        msg = "失败"
           }


}d